#ifndef QIPAN_H
#define QIPAN_H

#include <QObject>
#include <QPainter>
#include <QPaintEvent>
#include <QWidget>
#include <QMouseEvent>
#include "stdshared.h"

class qipan : public QWidget
{
    Q_OBJECT
public:
    explicit qipan(QWidget *parent = nullptr);
public:
    /*记录棋盘位置对应的玩家*/
    void setBoardInfo(int row,int col,Role role);
    /*得到棋盘信息*/
    Role ** getBoardInfo(int & boardSize);

    int getBoardSize();
protected:
    /*绘画事件*/
    void paintEvent(QPaintEvent *event);
    /*鼠标移动事件*/
    void mouseMoveEvent(QMouseEvent *event);
    /*鼠标点击事件*/
    void mousePressEvent(QMouseEvent *event);

signals:
    /*发送落子信号*/
    void chessClick(int row,int col);

public slots:

private:
     static const int m_boardSize = 15;    // 15*15
     static const int m_cellSize = 40;
     static const int m_margin = m_cellSize/2; // 边缘距离

     /* 玩家是1，人机是2 */
//     Role m_board[m_boardSize][m_boardSize];
     Role **m_board;

//     QVector<QPair<int,int>>m_board;

     /* 悬停坐标 */
     int m_hoverRow;
     int m_hoverCol;
     bool m_hoverFlag;
     bool m_clickedFlag;
};

#endif // QIPAN_H
